<template>
  <div class="friend-list listNearPersonClass">
    <template v-for="item in friendList" :key="item.id">
      <a-card :style="{ width: '360px' }" :title="item.userName">
        <template #extra>
          <a-link>删除好友</a-link>
        </template>
        <div>昵称：{{ item.friendName }}</div>
      </a-card>
      <!-- <div class="friend-item">{{ item }}</div> -->
    </template>
  </div>
</template>

<script setup lang="ts">
import { getFriendById } from "@/apis/oldman";
import { commonRequest } from "@/utils/request";
import { onMounted, ref } from "vue";

const userInfo = ref(null);

const getFriendList = async () => {
  if (import.meta.env.VITE_APP_OLDMAN_API_BASE_URL === "car") {
    const res = await commonRequest.post(
      "friends/select",
      `${userInfo.value.id}`
    );
    friendList.value = res.data.date;
  } else {
    const res = await getFriendById({ id: userInfo.value.id });
    friendList.value = res.data.data;
  }
};
const friendList = ref([]);

onMounted(() => {
  userInfo.value = JSON.parse(localStorage.getItem("userInfo") || "{}");
  getFriendList();
});
</script>

<style scoped>
.listNearPersonClass {
  display: flex;
  flex-direction: column;
  align-items: center;
}
</style>
